const qs = require('qs');
const bookTypeModel = require('../models/storytype');
const ctrlObj = {
	//获取小说类型列表
	getBookTypeList(callback) {
		bookTypeModel.getBookTypeListModel(data => {
			callback(data);
		});
	},
	//创建小说类型
	createBookType(params, callback) {
		params.typesort = params.typesort || 255;
		bookTypeModel.createBookTypeModel(params, data => {
			callback(data);
		});
	},
	//更新小说类型
	updateBookType(params, callback) {
		bookTypeModel.updateBookTypeModel(params.id, {
			"typename": params.name
		}, data => {
			callback(data);
		});
	},
	//删除小说类型
	delBookType(id, callback) {
		bookTypeModel.deleteBookTypeModel(id,data => {
			callback(data);
		});
	},
	//更新小说类型排序
	sortBookType(params, callback) {
		let param = qs.parse(qs.stringify(params)).sorts;
		bookTypeModel.updateBookTypeSortModel(param, data => {
			callback(data);
		})
	}
}

module.exports = ctrlObj;